<template>
<div class="CenterContainer">
  <div class="center">
    <div class="flex">
      <!--    左-->
      <el-space direction="vertical" :size="1">
        <el-card class="box-card">
          <div class="grid-content ep-bg-purple">
            <div v-if="!profileInfo.avatar" class="userAva">
              <el-avatar  src="https://rs.dance365.com/default_head@3x.png?imageView2/0/w/200/h/1200/ignore-error/1" :size="100"/>
            </div>
            <div v-else>
              <el-avatar
                  :src="profileInfo.avatar"
                  :size="100"
              />
            </div>
            <div>
              <p>{{ profileInfo.account ? profileInfo.account:'用户姓名' }}</p>
              <el-button size="small" class="btn"><i></i><i></i></el-button>
            </div>
            <div class="fans">
              <div>
                <p>0</p>
                <span>关注</span>
              </div>
              <div>
                <p>0</p>
                <span>粉丝</span>
              </div>
            </div>
          </div>

        </el-card>
        <el-card class="box-card">
          <router-link class="router-a" @click="go('资源动态')" :to="{name:'Dynamics'}" >资源动态</router-link>
        </el-card>
        <el-card class="box-card list">
          <router-link class="router-a" @click="go('我的会员')" :to="{name:'Vip'}">我的会员</router-link>
          <router-link class="router-a" @click="go('我的钱包')" :to="{name:'Dynamics'}">我的钱包</router-link>
          <router-link class="router-a" @click="go('我的优惠券')" :to="{name:'Dynamics'}">我的优惠券</router-link>
          <router-link class="router-a" @click="go('我买的订单')" :to="{name:'Dynamics'}">我买的订单</router-link>
          <router-link class="router-a" @click="go('我卖的')" :to="{name:'Dynamics'}">我卖的</router-link>
        </el-card>
        <el-card class="box-card">
          <router-link class="router-a" @click="go('我的资料')" :to="{name:'Profile'}">我的资料</router-link>
        </el-card>
      </el-space>
      <!--    右-->
      <el-space direction="vertical" class="right">
        <el-card class="box-card" >
          <span>{{title}}</span>
        </el-card>
        <el-card class="box-card rightCard" >
          <router-view :profileInfo="profileInfo"/>
        </el-card>
      </el-space>
    </div>
  </div>
</div>
</template>

<script lang="ts">
import {defineComponent} from "vue";

export default defineComponent({
  name: "Center",
});

</script>

<script lang="ts" setup>
import {useRouter} from "vue-router";
import {onMounted, ref} from "vue";
import {reqProfile} from "@/api/profile";

const $router = useRouter()
onMounted(()=>{
  getProfile()
})
const go = (x : string)=>{
  title.value = x
}
const profileInfo = ref<any>({})
const title = ref<string>('资源动态')

const getProfile = async () => {
  try {
    const re = await reqProfile()
    profileInfo.value = re.data
  } catch (e: any) {
    alert(e.message)
  }
}
</script>

<style lang="scss" scoped>
.CenterContainer{
  width: 100%;
  background-color: #f5f7f9;
}
.center{
  width: 1200px;
  margin: 0px auto;
  padding-top: 20px;
  .flex{
    display: flex;
    justify-content:space-between;
    .router-a{
      text-decoration:none;
      color:#000;
      cursor:pointer;
      border-left: 5px solid #ffffff;
    }
    .router-a:hover{
      border-left: 5px solid #f93684;
    }
    .active{
      border-left: 5px solid #f93684;
    }
  }
}
.box-card{
  margin: 5px 10px;
  background-color: #ffffff;
  width: 160px;
  border-radius: 4px;
  .grid-content{
    .userAva{
      text-align: center;
    }
    div{
      text-align: center;
      .btn{
        background: linear-gradient(#ff289b,#ff43d0);
        color: #f9f9f9;
        border-radius: 4px;
        padding-left: 8px;
        :nth-of-type(1){
          width: 15px;
          height: 10px;
          background-image: url(https://rs.dance365.com/level_Lv.@3x.png);
          display: inline-block;
          background-size: 100%;
          background-repeat: no-repeat;
        }
        :nth-of-type(2){
          width: 8px;
          height: 10px;
          display: inline-block;
          background-size: 100%;
          background-repeat: no-repeat;
          background-image: url(https://rs.dance365.com/level_num_1@3x.png);
        }
      }
    }
    .fans{
      display: flex;
      justify-content: center;
      div{
        margin: 0 10px;
        margin-top:20px;
      }
    }
  }
}
.list{
  :nth-of-type(1){
    margin-top: -5px;
  }
  :last-child{
    margin-bottom: -5px;
  }
  a{
    display: inline-block;
    margin: 5px 0;
    height: 40px;
    line-height: 40px;
    cursor:pointer;
  }
}
.right{
  margin-bottom: 80px;
  .box-card{
    width: 1000px;
  }
}

</style>
